package com.sport.config;


import com.sport.service.MiniHttpService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.support.WebClientAdapter;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;

@Configuration
public class HttpInterfaceConfig {

    @Bean
    public WebClient webClient(){
        return WebClient.builder().build();
    }
    @Bean
    public MiniHttpService miniHttpService(WebClient client){
        //请求的代理工厂
        HttpServiceProxyFactory build =  HttpServiceProxyFactory.builder().exchangeAdapter(WebClientAdapter.create(client)).build();
        //构建成自己的http声明接口
        return build.createClient(MiniHttpService.class);
    }
}
